﻿using System;

namespace CoreRay
{
    //-----------------------------------------------------------------------------------------
    /// <summary>
    /// Abstract class used by the <see cref="Film"/> class for image reconstruction.
    /// </summary>
    //-----------------------------------------------------------------------------------------

    public abstract class Filter
    {
        //-----------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="Filter"/> class.
        /// </summary>
        /// <param name="width">Width of the filter.</param>
        /// <param name="height">Height of the filter.</param>
        //-----------------------------------------------------------------------------------------

        protected Filter(float width, float height)
        {
            if(width < 0.0f)
            {
                throw new ArgumentException("Width cannot be negative.", "width");
            }

            if(height < 0.0f)
            {
                throw new ArgumentException("Height cannot be negative.", "height");
            }

            this.Width = width;
            this.Height = height;
        }


        //-----------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the width of the filter.
        /// </summary>
        /// <value>Width of the filter.</value>
        //-----------------------------------------------------------------------------------------

        public float Width
        {
            get;
            private set;
        }


        //-----------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the height of the filter.
        /// </summary>
        /// <value>Height of the filter.</value>
        //-----------------------------------------------------------------------------------------

        public float Height
        {
            get;
            private set;
        }


        //-----------------------------------------------------------------------------------------
        /// <summary>
        /// Evaluates the value of the filter at the specified (x, y) point.
        /// </summary>
        /// <param name="x">The x coordinate.</param>
        /// <param name="y">The y coordinate.</param>
        /// <returns>value of the filter at the specified (x, y) point.</returns>
        //-----------------------------------------------------------------------------------------

        public abstract float Evaluate(float x, float y);
    }
}
